﻿/// <reference path="../libs/underscore.js" />
/// <reference path="../libs/angular.js" />


function HomeController($scope, $http) {
    $http.get("scripts/data/homeInfo.js")
    .success(function (homeInfo) {
        $scope.homeInfo = homeInfo;
    })
}

function AboutController($scope, $http, $routeParams) {
    //$http.get("scripts/data/videos.js")
    //    .success(function (videos) {
    //        $scope.videos = videos;
    //    })

    $http.get("scripts/data/people.js")
        .success(function (people) {
            $scope.people = people;
        });
    $scope.toggle = true;
    $scope.ToggleIn = function (man) {
        man.showSpan = !man.showSpan;
        return man.showImg = !man.showImg;
        //console.log(e);
        //$(this).fadeOut(1000);
        //angular.element(e.srcElement).addClass('tHi')
        //console.log(this);
        //console.log(angular.element(e.srcElement));
        //alert("kurec");
    };
}

function ContactController($scope, $http, $routeParams) {
    $http.get("scripts/data/contacts.js")
        .success(function (contacts) {
            $scope.contacts = contacts;
        })
}

function ServiceController($scope, $http, $routeParams) {
    $http.get("scripts/data/services.js")
        .success(function (services) {
            $scope.services = services;
        })
}


function SingleServiceController($scope, $http, $routeParams) {
    var alias = $routeParams.alias;
    $http.get("scripts/data/services.js")
	    .success(function (allServices) {
	        var singleService = _.where(allServices, { "alias": alias });
	        $scope.services = singleService;
	    })
}

//function PostsController($scope, $http) {
//	$scope.newPost = {
//		title: "",
//		content: "",
//		category: ""
//	};

//	$http.get("scripts/data/posts.js")
//	.success(function (posts) {
//		$scope.posts = posts;
//		$scope.categories = _.uniq(_.pluck(posts, "category"));
//		$scope.selectedCategory = $scope.categories[0];
//	});
//	$scope.addPost = function () {
//		$scope.posts.push($scope.newPost);
//		var category = $scope.newPost.category;
//		if (!_.contains($scope.categories, category)) {
//			$scope.categories.push(category);
//		}

//		$scope.newPost = {
//			title: "",
//			content: "",
//			category: ""
//		};
//	}
//}

//function SinglePostController($scope, $http, $routeParams) {
//	var id = $routeParams.id;
//	$http.get("scripts/data/posts.js")
//	.success(function (posts) {
//		var post = _.first(_.where(posts, { "id": parseInt(id) }));
//		debugger;
//		$scope.post = post;
//	})
//}

//function CategoryController($scope, $http, $routeParams) {
//	var categoryName = $routeParams.name;

//	$http.get("scripts/data/posts.js")
//	.success(function (posts) {
//		var category = {
//			name: categoryName,
//			posts: []
//		};
//		_.chain(posts)
//		.where({ "category": categoryName })
//		.each(function (post) {
//			category.posts.push({
//				id: post.id,
//				title: post.title,
//				content: post.content
//			});
//		})
//		$scope.category = category;
//	})
//};